import instance from "./http";

export const uploadPostPicture = (param, config) => instance.post('/file/uploadPostPhoto', param, config)
//上传图片

export const deletePostPhoto = (filename) => instance.post('/file/deletePostPhoto', {
    file: filename
})//删除图片

export const postTopic = (param) => instance.post('/post/addPost', {
    ...param
})//新增帖子

export const editTopic = (param, postNo) => instance.post('/post/modifyPost', {
    ...param,
    postNo: postNo
})//修改帖子

export const getSubCommunity = (user_no) => instance.get(`/communityInformation/queryCommunityCollection?user_no=${user_no}`)
//获取用户关注社区

export const getMixedHotPosts = (user) => instance.post(`/post/find?user_no=${user.userNo}`, {})
//发现页初始加载

export const getHotCommunities = () => instance.get('/communityInformation/listCommunityAll')
//获取按热度排序的社区

export const getHotPosts = (communityNo) => instance.get(`/post/queryHotCommunityPost?communityNo=${communityNo}`)
//获取某个吧里按热度排序的帖子

export const getPost = (postNo, userNo) => instance.post(`/post/queryPostAndUser`, {
    postNo: postNo,
    user_no: userNo
})//获取某一帖子信息

export const getUserRecommandation = (user) => instance.get(`/post/recommend?user_no=${user.userNo}`)
//获取用户推荐页

export const getUserLikePosts = (user) => instance.get(`/post/like?user_no=${user.userNo}`)
//获取用户关注页

export const setLike = (userNo, likeObjectNo, likeObjectType) => instance.post('/userLikes/UserLikes', {
    userNo: userNo,
    likeObjectNo: likeObjectNo,
    likeObjectType: likeObjectType
})//更改点赞信息

export const setCollection = (userNo, collectionObjectNo, collectionObjectType) => instance.post('/userCollection/UserCollection', {
    userNo: userNo,
    collectionObjectNo: collectionObjectNo,
    collectionObjectType: collectionObjectType
})//更改收藏信息

export const setReport = (userNo, reportObjectNo, reportObjectType, reportTime, reportReason) => instance.post('/report/addUserReport', {
    userNo: userNo,
    reportObjectNo: reportObjectNo,
    reportObjectType: reportObjectType,
    reportTime: reportTime,
    reportReason:reportReason
})//举报

export const addComment = (postNo, userNo, commentTime, commentContent,replyNo,commentSort) => instance.post('/comment/addComment', {
    postNo: postNo,
    userNo: userNo,
    commentTime: commentTime,
    commentContent: commentContent,
    replyNo:replyNo,
    commentSort:commentSort//最大父评论接口
})//添加评论

export const getHotComments = (post_no, user_no) => instance.post(`/comment/queryHotComment`, {
    post_no: post_no,
    user_no: user_no
})//获取按热度排序评论

export const getSubComments = (commentNo,userNo) => instance.post(`/comment/queryReply`,{
    commentNo:commentNo,
    userNo: userNo
})
//获取某一评论下的子评论


export const getAllSubComments = (commentNo,userNo) => instance.post(`/comment/queryFather`,{
    commentNo:commentNo,
    userNo: userNo
})
//获取某一评论下的所有评论


export const getUserReplied=(replyNo) => instance.get(`/comment/queryReplyUser?replyNo=${replyNo}`)
//获取某一评论被回复者信息

export const getCommentsOrderByTime = (post_no) => instance.get(`/comment/queryPostComment?post_no=${post_no}`)
//获取按时间排序评论

export const deleteComment = (commentNo) => instance.post(`/comment/dropComment?commentNo=${commentNo}`)
//删除评论

export const getCommunityDetail = (communityNo) => instance.get(`/communityInformation/listCommunity?communityNo=${communityNo}`)
//获取吧信息

export const getCommunityPosts = (communityNo) => instance.get(`/post/queryHotCommunityPost?communityNo=${communityNo}`)
//获取某一吧内帖子

export const subCommunity = (userNo, collectionObjectNo, collectionObjectType) => instance.post(`/userCollection/UserCollection`, {
    userNo: userNo,
    collectionObjectNo: collectionObjectNo,
    collectionObjectType: collectionObjectType
})//关注社区

export const deletePost = (postNo) => instance.post('/post/dropPost', {
    postNo: postNo
})//删除帖子

export const getNotifacations = (userNo) => instance.post('/userLikes/findOtherToUser', {
    userNo: userNo
})//获取当前用户通知

export const getTags = () => instance.get(`/label/findAllLabel`)
//获取标签

export const getRandomTags = () =>instance.get('/label/findLabelByRand')

export const addTag = (labelName) =>instance.post('/label/addLabel',{
    labelName: labelName
})//增加标签

export const giveAndRemoveTags=(tags,config) => instance.post('/labelRelation/changeLabelRe',tags,config)//新增以及删除标签，ob待新增标签对象，obType为待新增标签对象的类型，0为社区，1为帖子，2为用户

export const findRelatedTags = (obNo,obType) => instance.post('/labelRelation/queryLabelByob',{
    obNo:obNo,
    obType:obType
})//查找相关标签，ob待查找相关标签对象，obType为查找标签对象的类型，0为社区，1为帖子，2为用户

export const findTagRelatedPosts = (labelNo) =>instance.get(`/labelRelation/queryPostByLabel?labelNo=${labelNo}`)
//查找某标签下的所有帖子

export const getTagRecommandPosts = (userNo) =>instance.get(`/labelRelation/recommendPost?userNo=${userNo}`)
//根据用户标签推荐帖子

export const addCommunityManager = (userNo,communityNo,manageLv) => instance.post('/communityManagement/addCommunityManagement',{
    userNo:userNo,
    communityNo:communityNo,
    manageLv:manageLv
})//添加社区管理员，manageLv为管理员权限

export const removeCommunityManager = (managementNo) => instance.post('/communityManagement/communityManagement',{
    managementNo:managementNo
})//删除社区管理员，传递相关关系表主键

export const getCommunityManagedByMe = (userNo) => instance.get(`/communityManagement/queryCommunityManagementByUser?userNo=${userNo}`)
//获取我管理的所有社区

export const getCommunityManagers = (communityNo) => instance.get(`/communityManagement/queryCommunityManagementByCommunity?communityNo=${communityNo}`)
//获取社区所有管理员

export const getChatList = (userName) => instance.get('/chat/getChatList?userName=' + userName)
//获取聊天List

export const getMessageRecord = (receiver,sender) => instance.get('/chat/getMessageRecord?amount=100&receiver=' + receiver + '&sender=' + sender)
//获取聊天记录

export const setUserListId = (userNo,listId) => instance.get('/chat/setUserListId?user_no=' + userNo + '&listId=' + listId)
//设置用户listId
export const getPersonalInfo = (userNo) => instance.get(`/userDetails/queryUserDetailsByUser?userNo=${userNo}`)
//获取该用户的个人信息
export const updatePersonalInfo = (userInformationNo,userNo,userNickname,userQq,userGender,userSynopsis,userSchool,userPlace) => instance.post(`/userDetails/modifyUserDetails`,{
    userInformationNo:userInformationNo,
    userNo:userNo,
    userNickname:userNickname,
    userQq:userQq,
    userGender:userGender,
    userSynopsis:userSynopsis,
    userSchool:userSchool,
    userPlace:userPlace
})
//更新该用户的个人信息
export const updateCommunityInfo = (communityNo,communityName,communitySynopsis) => instance.get(`/communityInformation/updateCommunity?communityNo=${communityNo}&communityName=${communityName}&communitySynopsis=${communitySynopsis}`)

//更新该社区信息
export const getCommunityReport = (communityNo) => instance.get(`/report/queryAllCommunityReport?communityNo=${communityNo}`)
//获取社区的举报信息

export const replyReport = (reportNo,reportRejection) => instance.post(`/report/modifyUserReport`,{
    reportNo:reportNo,
    reportRejection:reportRejection,

})
//对举报信息进行回复

export const getPostName = (postNo) => instance.get(`/post/queryPost?postNo=${postNo}`)
//获取莫一个帖子的name

export const setListIdRead = (listId) => instance.post('/chat/setListIdRead?listId=' + listId)
//设置某消息列表已读

export const getUserInfo = (userNo) => instance.post('/userInformation/queryUserInformation?userNo=' + userNo)
//获取用户Info

export const addChatList = (sender,receiver) => instance.post('chat/addChatList?sender=' + sender + '&receiver=' + receiver)
//新增chatList

export const getAllUserInfo=()=>instance.get('/userInformation/findAllUser')
export const getSelectToCollection=(userNo)=>instance.post('/notification/selectToCollection?userNo='+userNo)

export const commentCheck = (comment,config)=>instance.get(`/check?comment=${comment}`,config)
//评论审核

export const judgeUserSubComm = (userNo,collectionObjectNo,collectionObjectType) => instance.post('/userCollection/UserCollectionCommunity',{
    userNo:userNo,
    collectionObjectNo:collectionObjectNo,
    collectionObjectType:collectionObjectType
})//判断是否关注过某社区

export const searchPost = (keyword)=>instance.post('/post/selectPostByKey',{
    keyword:keyword
})